import 'package:gluz/generated/json/base/json_convert_content.dart';
import 'package:gluz/app/data/shop/shop_category_entity.dart';

ShopCategoryEntity $ShopCategoryEntityFromJson(Map<String, dynamic> json) {
  final ShopCategoryEntity shopCategoryEntity = ShopCategoryEntity();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    shopCategoryEntity.id = id;
  }
  final String? parentId = jsonConvert.convert<String>(json['parentId']);
  if (parentId != null) {
    shopCategoryEntity.parentId = parentId;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    shopCategoryEntity.name = name;
  }
  final int? level = jsonConvert.convert<int>(json['level']);
  if (level != null) {
    shopCategoryEntity.level = level;
  }
  final String? path = jsonConvert.convert<String>(json['path']);
  if (path != null) {
    shopCategoryEntity.path = path;
  }
  final int? sortOrder = jsonConvert.convert<int>(json['sortOrder']);
  if (sortOrder != null) {
    shopCategoryEntity.sortOrder = sortOrder;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    shopCategoryEntity.status = status;
  }
  final String? description = jsonConvert.convert<String>(json['description']);
  if (description != null) {
    shopCategoryEntity.description = description;
  }
  final String? images = jsonConvert.convert<String>(json['images']);
  if (images != null) {
    shopCategoryEntity.images = images;
  }
  final String? createdAt = jsonConvert.convert<String>(json['createdAt']);
  if (createdAt != null) {
    shopCategoryEntity.createdAt = createdAt;
  }
  final String? updatedAt = jsonConvert.convert<String>(json['updatedAt']);
  if (updatedAt != null) {
    shopCategoryEntity.updatedAt = updatedAt;
  }
  final double? aspectRatio = jsonConvert.convert<double>(json['aspectRatio']);
  if (aspectRatio != null) {
    shopCategoryEntity.aspectRatio = aspectRatio;
  }
  final bool? isSelected = jsonConvert.convert<bool>(json['isSelected']);
  if (isSelected != null) {
    shopCategoryEntity.isSelected = isSelected;
  }
  return shopCategoryEntity;
}

Map<String, dynamic> $ShopCategoryEntityToJson(ShopCategoryEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['parentId'] = entity.parentId;
  data['name'] = entity.name;
  data['level'] = entity.level;
  data['path'] = entity.path;
  data['sortOrder'] = entity.sortOrder;
  data['status'] = entity.status;
  data['description'] = entity.description;
  data['images'] = entity.images;
  data['createdAt'] = entity.createdAt;
  data['updatedAt'] = entity.updatedAt;
  data['aspectRatio'] = entity.aspectRatio;
  data['isSelected'] = entity.isSelected;
  return data;
}

extension ShopCategoryEntityExtension on ShopCategoryEntity {
  ShopCategoryEntity copyWith({
    String? id,
    String? parentId,
    String? name,
    int? level,
    String? path,
    int? sortOrder,
    int? status,
    String? description,
    String? images,
    String? createdAt,
    String? updatedAt,
    double? aspectRatio,
    bool? isSelected,
  }) {
    return ShopCategoryEntity()
      ..id = id ?? this.id
      ..parentId = parentId ?? this.parentId
      ..name = name ?? this.name
      ..level = level ?? this.level
      ..path = path ?? this.path
      ..sortOrder = sortOrder ?? this.sortOrder
      ..status = status ?? this.status
      ..description = description ?? this.description
      ..images = images ?? this.images
      ..createdAt = createdAt ?? this.createdAt
      ..updatedAt = updatedAt ?? this.updatedAt
      ..aspectRatio = aspectRatio ?? this.aspectRatio
      ..isSelected = isSelected ?? this.isSelected;
  }
}